<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>订单查询列表</title>
	<%@ include file="/view/common/tags.jsp"%>
	<script type="text/javascript" src="${sysManagerV1}/js/My97DatePicker/WdatePicker.js"> </script>
</head>
<body>
	<section class="content">
    	<div class="row">
            <div class="col-md-12">
                <div class="box">
                	<div class="box-body">
						<div class="panel panel-default">
                            <div class="panel-body" style="padding-bottom:5px;">
                                <form class="form-horizontal" action="" method="post" id="dataForm">
                                    <input type="hidden" id="token" name="token" value="" />
                                	<div class="searchMenu">
                                	    <div>
                                            <label>游戏名称：</label>
                                            <sk:select cssClass="form-control select" id="gameId" name="wm[GAME_ID]" value="${page.wm.GAME_ID}" requiredInit="true" ajaxURL="${userInfoV1}/baseGame/gameSelect?wm[USE_FLAG]=1&wm[DEL_FLAG]=1" onchange="TagUtil.fillOptions('gameId');">
                                                <option value="">请选择</option>
                                                <sk:options  options="${gameNameList}" ></sk:options>
                                            </sk:select>
                                        </div>
                                        <div>
                                            <label>游戏区：</label>
                                            <sk:select cssClass="form-control select" id="areaId" name="wm[AREA_ID]" value="${page.wm.AREA_ID}" ajaxURL="${userInfoV1}/baseArea/select?wm[USE_FLAG]=1&wm[DEL_FLAG]=1" parentCascadedSelect="gameId" parentParamName="gameId" onchange="TagUtil.fillOptions('areaId');" >
                                                <option id="area_id" value="">请选择</option>
                                            </sk:select>
                                        </div>
                                        <div>
                                            <label>游戏服：</label>
                                            <sk:select cssClass="form-control select" id="serverId" name="wm[SERVER_ID]" value="${page.wm.SERVER_ID}" ajaxURL="${userInfoV1}/baseServer/select?wm[USE_FLAG]=1&wm[DEL_FLAG]=1" parentCascadedSelect="areaId" parentParamName="areaId">
                                                <option id="server_id" value="">请选择</option>
                                            </sk:select>
                                        </div>
                                        <div>
                                            <label>商品类型：</label>
                                            <sk:select cssClass="form-control select" id ="goodsBigId" name="wm[GOODS_BIG_ID]" value="${page.wm.GOODS_BIG_ID}" onchange="TagUtil.fillOptions('goodsBigId');">
                                                <option value="">请选择</option>
                                                <option value="10">游戏币</option>
                                                <option value="11">装备</option>
                                            </sk:select>
                                        </div>
                                        <div>
                                            <label>商品小类：</label>
                                            <sk:select cssClass="form-control select" id ="goodsSmallId" name="wm[GOODS_SMALL_ID]" value="${page.wm.GOODS_SMALL_ID}" parentCascadedSelect="goodsBigId" parentParamName="wm[TYPE_FLAG]" ajaxURL="${userInfoV1}/gameGoodsType/smallTypeSelect">
                                                <option value="">请选择</option>
                                            </sk:select>
                                        </div>
                                        <div>
                                		    <label>订单编号：</label>
                                            <input type="text" class="form-control" name="wm[_LIKE$ORDER_NO]" value="${page.wm._LIKE$ORDER_NO}" placeholder="请输入订单编号">
                                        </div>
                                        <div>
                                            <label>交易类型：</label>
                                        	<sk:select cssClass="form-control select" id ="tradeId" name="wm[TRADE_ID]" value="${page.wm.TRADE_ID}" requiredInit="true" ajaxURL="${tradeV1}/tradeState/tradeTypeDictList">
							                	<option value="">请选择</option>
							            	</sk:select>
                                        </div>
                                        
	                                    <div class="glType">
                                            <label>订单状态：</label>
                                            <sk:select cssClass="form-control select" id="orderState" name="wm[ORDER_STATE]" value="${page.wm.t1.ORDER_STATE}" requiredInit="true" ajaxURL="${tradeV1}/tradeState/orderStateDictList">
                                                <option  value="">请选择</option>
                                            </sk:select>
                                        </div>
                                        <div>
                                            <label>卖家账号：</label>
                                            <input type="text" class="form-control" name="wm[_LIKE$SELLER_ACCOUNT]" value="${page.wm._LIKE$SELLER_ACCOUNT}" placeholder="请输入卖家账号">
                                        </div>
                                        <div style="width:300px;">
                                            <label>买家账号：</label>
                                            <input type="text" class="form-control" name="wm[_LIKE$BUYER_ACCOUNT]" value="${page.wm._LIKE$BUYER_ACCOUNT}" placeholder="请输入买家账号">
                                        </div>
                                        <div>
                                            <label>下单时间：</label>
                                            <input id="createTimeStart" name="wm[_MORE_EQUAL$TIME_ORDER_CREATE]" value="${page.wm._MORE_EQUAL$TIME_ORDER_CREATE}"  type="text"  class="Wdate" 
											  onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',startDate:'%y-%M-%d 00:00:00',alwaysUseStartDate:true,maxDate:'#F{$dp.$D(\'createTimeEnd\')}',minDate:'#F{$dp.$D(\'createTimeEnd\',{d:-30,H:-23,m:-59,s:-59})}'})" /> 
											  <span class="pull-left">&nbsp;-&nbsp;</span>
											  <input id="createTimeEnd" name="wm[_LESS_EQUAL$TIME_ORDER_CREATE]" value="${page.wm._LESS_EQUAL$TIME_ORDER_CREATE}"  class="Wdate" 
								               onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',startDate:'%y-%M-%d 23:59:59',alwaysUseStartDate:true,minDate:'#F{$dp.$D(\'createTimeStart\')}',maxDate:'#F{$dp.$D(\'createTimeStart\',{d:+30,H:+23,m:+59,s:+59})}'})" />
                                        </div>
                                        <div class="mal10" >
                                            <button type="button"  class="btn btn-primary btn-sm"  onclick="findData()"><span class='glyphicon glyphicon-search'></span>查&nbsp;询</button>
                                            <!-- <button type="button"  class="btn btn-primary btn-sm"  onclick="addOrder()"><span class='glyphicon glyphicon-plus'></span>录&nbsp;单</button> -->
                                        </div>
                                	</div>
                                </form>
                        	</div>
						</div>
                        <table class="table table-hover table-condensed table-bordered table-striped" id="dataTable" >
                            <thead>
                            	<tr>
                                	<th data-field="index" data-align="center" data-formatter="indexFormatter" data-sortable="false" style="width:100px;">序号</th>
                                	<th data-field="orderNo" data-align="center" data-sortable="true">订单编号</th>
                                	<th data-field="gameName" data-align="center" data-sortable="false" data-formatter="gameInfoFormatter">游戏信息</th>
                                	<th data-field="goodsName" data-align="center" data-sortable="false">商品标题</th>
                                    <th data-field="tradeName" data-align="center" data-sortable="false">交易类型</th>
                                    <th data-field="goodsSmallName" data-align="center" data-sortable="true">商品小类</th>
                                    <th data-field="sellerAccount" data-align="center" data-sortable="true">卖家帐号</th>
                                    <th data-field="buyerAccount" data-align="center" data-sortable="true">买家帐号</th>
									<th data-field="orderSumFee" data-align="center" data-sortable="true">订单金额</th>
                                    <th data-field="orderState" data-align="center" data-sortable="true" data-formatter="orderStateFormatter">订单状态</th>
                                	<th data-field="timeOrderCreate" data-align="center" data-sortable="true">下单时间</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
       	</div>
	</section>
   <%@ include file="/view/common/footer.jsp"%>
</body>
<script>
// 提示信息
var msgg='<%=request.getAttribute("msg")%>';
if (msgg && msgg!=null && msgg!='null') { 
	  layer.msg(msgg);
}
var tableIndex = 0; // 添加修改的弹出框的ID
var orderStateDictList = "" // 订单状态字典数据

$(function(){
    $("#token").val(sessionStorage.getItem("token"));
    
    // 获取订单状态信息
    $.ajax({
    	type: "post",
    	url: "${tradeV1}/tradeState/orderStateDictList",
    	dataType: "json",
    	success: function(data){
    		orderStateDictList = data;
    	}
    });
    
    // 加载table 数据
    $("#dataTable").bootstrapTable({ 
        url: "${tradeV1}/tradeOrders/data.json",
        method:"get", 
        contentType: "application/x-www-form-urlencoded",
        pagination:true,
        sidePagination:"server",
        queryParams: function(params) {
            //alert(JSON.stringify(params));
            return $.extend({}, params, parseJson(decodeURIComponent($("#dataForm").serialize())));     
        }
    });
})

// 游戏信息 字段格式化
function gameInfoFormatter(value, row, index) {
    return row.gameName + " / " + row.areaName + " / " + row.serverName;
}

// 订单状态 字段格式化
function orderStateFormatter(value, row, index) {
    var orderState = "";
    for(var i in orderStateDictList){
    	if(orderStateDictList[i]["value"] == value){
    		orderState = orderStateDictList[i]["label"];
    	}
    }
    if(value == 10 && row.financeState == 20){
        orderState = "已支付";
    }
    if(value == 0 && row.financeState == 30){
        orderState = "已完成（未到账）";
    }
    if(value == 0 && row.financeState == 40){
        orderState = "已完成（已到账）";
    }
    return orderState;
}
    
// 查询
function findData(){
   $("#dataTable").bootstrapTable("refresh",{} ); 
} 

// 行点击事件
$(function(){
     $("body").on("click","table>tbody>tr",function(){
      $(this).css("background","#e1ecf1").siblings().css("background","");
   });
})
</script>
</html>